package com.tanhua.manage.job;

import com.tanhua.manage.service.AnalysisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Slf4j
public class AnalysisJob {

    //注入AnalysisJob
    @Autowired
    private AnalysisService analysisService;
    //每隔12个小时统计一次信息
    @Scheduled(cron = "0 0 6 * * ? ")
    public void analysis() {
        log.debug("开始统计日志信息："+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        analysisService.timedStatisticsLogInformation();
        log.debug("日志统计完毕~");
    }
}